﻿using BlogSystem.Model.Request;
using FluentValidation;

namespace BlogSystem.Common.Validation;

public class RegisterValidatior : AbstractValidator<RegisterRequest>
{
    
    public RegisterValidatior()
    {
        // 验证用户名不为空 ，同时也可以设置指定范围长度大小
        RuleFor(x => x.Name)
            .NotEmpty().WithMessage("Username is required.")
            .Length(3, 255).WithMessage("Username must be betweeb 3 and 255 characters.");
        
        // 验证密码不为空且长度在指定范围内
        RuleFor(x => x.Password)
            .NotEmpty().WithMessage("Password is required.")
            .Length(3, 255).WithMessage("Password must be at least 3 characters long.");
    }
}
